import React from 'react';
import { getAntd,getEcCom } from '../../util/convert';

export default class WeaSapBrowser extends React.Component{
    constructor(){
        super();
    }
    doBrowserChange = (_ids, _names, _datas) => {
        const { WeaTools } = getEcCom();
        const { weaBrowserProps,onChange } = this.props;
        const { fieldid,rowIndex,dataParams } = weaBrowserProps||{};
        const { fielddbtype,requestid } = dataParams;
        let params = {fromNodeorReport:"0", fieldid,rowIndex,requestid,fielddbtype};
        params["datas"] = JSON.stringify(_datas);
        //此接口由SAP模块提供，将浏览按钮选中数据转换为流程识别的数据
        WeaTools.callApi('/api/SapIntegration/browser/assignToBill', 'POST', params).then(result =>{
            onChange && onChange(result.datas);
        });
    }
    render(){
        const { WeaBrowser,WeaTools } = getEcCom();
        const { weaBrowserProps } = this.props;
        const {displaySearchAdInBar} = weaBrowserProps.dataParams;
        return (
            <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@dv69jt`} {...weaBrowserProps} onChange={this.doBrowserChange} sap={true} displaySearchAdInBar={displaySearchAdInBar} />
        )
    }
}